package bishihuizong;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Created by JiaJia on 2019/9/15 0015.
 */
public class ZhaoHang03 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String input=scanner.nextLine();
        char[] chars=input.toCharArray();
        List<String> list=new ArrayList<>();
        help(list,chars,0,chars.length);
        long res=0;
        for (String s:list) {
            if (Long.valueOf(s)%13==5){
                res++;
            }
        }
        res=res%10000000007l;
        System.out.println(res);
    }
    public static void help(List<String> list,char[] ch,int a,int b){
        if (a==b){
            list.add(new String(ch));
        }else {
            if (ch[a]=='?'){
                for (int i = 0; i <10; i++) {
                    ch[a]=(char)(i+'0');
                    help(list,ch,a+1,b);
                }
                ch[a]='?';
            }else{
                help(list,ch,a+1,b);
            }
        }
    }
}